package com.mjk.manager.magicapi.plugin.webservice.web;

import com.mjk.common.base.error.BeeError;
import com.mjk.common.base.response.BeeResponse;
import com.mjk.common.base.work.BaseWork;
import com.mjk.common.base.work.annotation.BeeWork;
import com.mjk.common.tools.springextend.BeeSpringBean;
import com.mjk.common.util.ObjectUtils;
import com.mjk.manager.api.dto.ApiDto;
import com.mjk.manager.magicapi.core.core.config.MagicConfiguration;
import com.mjk.manager.magicapi.core.core.config.WebSocketSessionManager;
import com.mjk.manager.magicapi.core.core.logging.MagicLoggerContext;
import com.mjk.manager.magicapi.core.core.model.DebugRequest;
import com.mjk.manager.magicapi.core.core.model.JsonBean;
import com.mjk.manager.magicapi.core.core.model.MagicEntity;
import com.mjk.manager.magicapi.core.core.servlet.MagicHttpServletRequest;
import com.mjk.manager.magicapi.core.core.web.MagicController;
import com.mjk.manager.magicapi.core.core.web.MagicExceptionHandler;
import com.mjk.manager.magicapi.core.utils.ScriptManager;
import com.mjk.manager.magicapi.plugin.webservice.constns.MagicWebServiceConstns;
import com.mjk.manager.magicapi.plugin.webservice.wsdl.MagicApiWsdlUtils;
import org.apache.cxf.bus.spring.SpringBus;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.ssssssss.script.MagicScriptDebugContext;

/**
 *
 */
@BeeWork(work = "soap")
public class MagicWebServiceController extends BaseWork {



    /**
     * 更具 wsdl获取soap报文
     * @param dto
     * @return
     */
    public BeeResponse getSoapContextByWsdl(ApiDto dto) {
        needParams(dto,ApiDto::getWsdl);
        SpringBus bus = BeeSpringBean.getBean(SpringBus.class);
        if(!dto.getWsdl().startsWith("http")){
            dto.setWsdl("http://localhost:"+ BeeSpringBean.getEnvValue(MagicWebServiceConstns.SERVER_PORT) +"/webservice/"+dto.getWsdl());
        }
        String soap = MagicApiWsdlUtils.getSoapProtocol(dto.getWsdl());
        return BeeError.BEE_SUC.tranceError(soap);
    }
}
